package com.example.aninterface;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

public class MeAdapter<textViewResourceId> extends ArrayAdapter<Me> {
    private  int resourceId;

    public MeAdapter(Context context, int textViewResourceId, List<Me> objects){
        super(context,textViewResourceId,objects);
        resourceId= textViewResourceId;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent){
        Me me = getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
        ImageView meImage=(ImageView) view.findViewById(R.id.me_image);
        TextView meName=(TextView) view.findViewById(R.id.me_name);
        meImage.setImageResource(me.getImageId());
        meName.setText(me.getName());
        return view;
    }
}
